package com.sky.mapper;

import com.sky.entity.FormTemplate;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface VueFormTemplateMapper {
    @Select("SELECT * FROM form_template")
    List<FormTemplate> findAll();

    @Insert("INSERT INTO form_template (template_name, description, field_group, create_time, update_time) " +
            "VALUES (#{templateName}, #{description}, #{fieldGroup}, NOW(), NOW())")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertFormTemplate(FormTemplate formTemplate);

    @Select("SELECT * FROM form_template WHERE id = #{id}")
    FormTemplate getTemplateById(Long id);

    @Update("UPDATE form_template SET template_name = #{templateName}, description = #{description}, " +
            "field_group = #{fieldGroup}, update_time = NOW() WHERE id = #{id}")
    void updateFormTemplate(FormTemplate formTemplate);

    @Delete("DELETE FROM form_template WHERE id = #{id}")
    void deleteTemplateById(Long id);
}